package com.demo.controller;

import com.bootlever.framework.redis.templates.RedisTemplate;
import org.redisson.api.RSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Set;

@RestController
public class RedisController {

    private static final Logger logger = LoggerFactory.getLogger(RedisController.class);

    @Autowired
    private RedisTemplate redisTemplate;

    @RequestMapping(value = "/redis")
    public String redistest() {
        redisTemplate.commands().set("name","zhangsan");
        String name = redisTemplate.commands().get("name");
        return name;
    }

    @RequestMapping(value = "/redisson")
    public String redisson(){
        RSet<String> set = redisTemplate.redisson().getSet("nnn");
        set.add("zhang");
        String name = redisTemplate.redisson().getSet("nnn").getName();
        Set<String> value = set.readAll();
        return value.toString();
    }
}
